
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<span style="font-size:18px;">
<html>
<head>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" type="text/css" href="approvalProcess/css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="approvalProcess/css/commonly-used-show.css" />
    <script type="text/javascript" src="approvalProcess/js/jquery.min.js"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap.js" ></script>
    <script type="text/javascript" src="approvalProcess/js/jquery.cookie.js"></script>

    <link rel="stylesheet" type="text/css" href="approvalProcess/css/bootstrap-datetimepicker.min.css" />
    <script src="https://cdn.bootcss.com/bootstrap-datetimepicker/4.17.47/js/bootstrap-datetimepicker.min.js"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap-datetimepicker.js" charset="UTF-8"></script>
    <script type="text/javascript" src="approvalProcess/js/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>

    <title>出入申请</title>

</head>
<body class="mybody">



 <jsp:include page="theTopMenuTeacher.jsp" />



 <div class="container-fluid">
    <div class="row">


        <div class="col-md-12">
            <div class="col-md-12">
                    <div class="panel panel-primary">
                        <div class="panel-body">
                            <div class="alert alert-info">


                                <div class="container">
        <h3 style="text-align: center">出入申请</h3>
        <hr style="filter: alpha(opacity=100,finishopacity=0,style=3)" width="100%" color="#6f5999" size="3" />

        <div id="add_apply" class="container">
            <div class="form-group same-line">
                <label><b style="color: red">*&nbsp</b>学院：</label>
                <select style="font-size:14px" class="form-control edit" title="请选择" id="name_college" data-live-search="true">
                    <option value="" disabled selected hidden>请选择</option>
                    <option value="继续教育学院">继续教育学院</option>
                    <option value="国际学院">国际学院</option>
                    <option value="大健康学院">大健康学院</option>
                     <option value="材料与化学工程学院">材料与化学工程学院</option>
                     <option value="大数据学院">大数据学院</option>
                    <option value="农林工程与规划学院">农林工程与规划学院</option>
                    <option value="经济管理学院">经济管理学院</option>
                    <option value="艺术学院">艺术学院</option>
                    <option value="人文学院">人文学院</option>
                    <option value="教育学院">教育学院</option>
                    <option value="马克思主义学院">马克思主义学院</option>
                    <option value="乌江学院">乌江学院</option>
                     <option value="国学院">国学院</option>
                </select>
            </div>


            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>职工号：</label>
                <input type="text" id="student_number" class="form-control edit" placeholder="请输入学号" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="15">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>姓名：</label>
                <input type="text" id="user_name" class="form-control edit" placeholder="请输入姓名" maxlength="6">
            </div>

            <div class="form-group same-line">
                <label ><b style="color: red">*&nbsp</b>用户性别：</label>
                <select style="font-size:14px" class="form-control edit" title="请选择" id="user_sex" data-live-search="true" >
                    <option value="" disabled selected hidden>请选择</option>
                    <option value="男">男</option>
                    <option value="女">女</option>
                </select>
            </div>


            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>本人联系方式：</label>
                <input type="text" id="user_tel" class="form-control edit" placeholder="请输入本人联系方式" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="11">
            </div>

            <div class="form-group same-line-left">
                <label ><b style="color: red">*&nbsp</b>出校时间：</label>
                <div class="controls input-append date form_datetime" data-date-format="dd MM yyyy - HH:ii p" data-link-field="start_time">
                    <input id="start_time" class="form-control edit" size="16" type="text" readonly placeholder="请选择" />
                    <span class="add-on"><i class="icon-remove"></i></span>
                    <span class="add-on"><i class="icon-th"></i></span>
                </div>
                <input class="form-control edit" type="hidden" />
            </div>

            <div class="form-group same-line">
                <label ><b style="color: red">*&nbsp</b>返校时间：</label>
                <div class="controls input-append date form_datetime" data-date-format="dd MM yyyy - HH:ii p" data-link-field="end_time">
                    <input id="end_time" class="form-control edit" size="16" type="text" readonly placeholder="请选择" />
                    <span class="add-on"><i class="icon-remove"></i></span>
                    <span class="add-on"><i class="icon-th"></i></span>
                </div>
                <input class="form-control edit" type="hidden"  />
            </div>

            <div class="form-group same-line-left">
                <label >出行方式：</label>
                <input type="text" id="trip_mode" class="form-control edit" placeholder="公交车/出租车/步行/地铁" maxlength="20" >
            </div>

            <div class="form-group same-line-left">
                <label >目的地：</label>
                <input type="text" id="destination" class="form-control edit" placeholder="请输入目的地" maxlength="20">
            </div>

            <div class="form-group same-line">
                 <label ><b style="color: red">*&nbsp</b>申请出校原因：</label>
                <textarea id="reasons_school" style="width:500px; height:124px; resize: none;" placeholder="请在此填写出校原因" class="form-control edit" rows="3" cols="50"></textarea>
            </div>

            <div class="form-group same-line-left">
                <label >出行路线：</label>
                <input type="text" id="travel_route" style="width: 500px" class="form-control edit" placeholder="地点A>地点B>地点C" maxlength="40">
            </div>


        </div>

        <div style="margin-top: 50px" class="form-group text-center same-line-clear">
            <input type="button" value="申请" class="btn btn-primary" onclick="addApply()">
            <input type="reset" value="重置" class="btn btn-danger interval" onclick="reset()">
        </div>

        <div class="text-center">
            <label id="user_null" style="color: red"></label>
        </div>

</div>


                            </div>
                        </div>
                    </div>
                </div>
        </div>



    </div>

 </div>


<script type="text/javascript">
    var userdt = JSON.parse(sessionStorage.getItem("user"));
    var userNull = document.getElementById("user_null");
    if (userdt.result.userName != null){
        $("#usname").text(userdt.result.userName);
    }else {
        $("#usname").text(userdt.result.userLoginName);
    }

    var counsellorId = "";

    function reset(){
        var addUser = document.getElementById("add_apply");
        var ipts = addUser.getElementsByTagName("input");
        for (var i = 0; i < ipts.length; i++){
            ipts[i].value = "";
        }
    }


    window.onload = function(){
        userInfo();
        userInfo1();
    }

    function userInfo1(){
        $("#name_college").val(userdt.result.userReplenish.belongsCollege);
        $("#professional_class").val(userdt.result.userReplenish.belongsClass);

        $("#student_number").val(userdt.result.userLoginName);
        $("#user_name").val(userdt.result.userName);
        $("#user_sex").val(userdt.result.userSex);
    }


    function userInfo(){
        var postUrl = "${pageContext.request.contextPath}/userClassGradeInfo";

        var str = {
            "belongsCollege": userdt.result.userReplenish.belongsCollege,
            "teacherCharge": "院领导"
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    userNull.innerHTML = data.msg;
                }else {
                    counsellorId = data.result.id;
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });

    }

    function addApply(){
        var mNameCollege = $("#name_college").val();
        var mStudentNumber = $("#student_number").val();
        var mUserName = $("#user_name").val();
        var mUserSex = $("#user_sex").val();
        var mUserTel = $("#user_tel").val();
        var mStartTime = $("#start_time").val();
        var mEndTime = $("#end_time").val();
        var mTripMode = $("#trip_mode").val();
        var mDestination = $("#destination").val();
        var mReasonsSchool = $("#reasons_school").val();
        var mTravelRoute = $("#travel_route").val();

        if ($.isEmptyObject(mNameCollege)){
            userNull.innerHTML = "学院不能为空";
            return false;
        }else if ($.isEmptyObject(mStudentNumber)){
            userNull.innerHTML = "职工号不能为空";
            return false;
        }else if ($.isEmptyObject(mUserName)){
            userNull.innerHTML = "姓名不能为空";
            return false;
        }else if ($.isEmptyObject(mUserSex)){
            userNull.innerHTML = "用户性别不能为空";
            return false;
        }else if ($.isEmptyObject(mUserTel)){
            userNull.innerHTML = "联系方式不能为空";
            return false;
        }else if ($.isEmptyObject(mStartTime)){
            userNull.innerHTML = "出校时间不能为空";
            return false;
        }else if ($.isEmptyObject(mEndTime)){
            userNull.innerHTML = "返校时间不能为空";
            return false;
        }else if ($.isEmptyObject(mReasonsSchool)){
            userNull.innerHTML = "出校原因不能为空";
            return false;
        }else {
            userNull.innerHTML = "";
        }


        var postUrl = "${pageContext.request.contextPath}/addAccessApplication";
        var str = {
            "scholasticId": userdt.result.id,
            "collegeLeadersId":counsellorId,
            "teacherStudentNumber": mStudentNumber,
            "userName": mUserName,
            "userSex": mUserSex,
            "contactNumber": mUserTel,
            "startTime": mStartTime,
            "endTime": mEndTime,
            "destination": mDestination,
            "tripMode": mTripMode,
            "pursueReason": mReasonsSchool,
            "travelRoute": mTravelRoute,
            "collegeName": mNameCollege,
            "accessStatus": "2",
            "myApproval": {
                "userLevel": userdt.result.userLevel,
                "approvalStatus": "2"
            }
        };

        $.ajax({
            type:"post",
            url:postUrl,
            headers: {
                "Content-Type":"application/json"
            },
            data:JSON.stringify(str),
            contentType: "application/json; charset=utf-8",
            dataType:"json",
            success:function(data){
                if (data.status == "0"){
                    userNull.innerHTML = data.msg;
                }else {
                    location.href = "${pageContext.request.contextPath}/myTeacherSponsorApplication?type=2";
                }

            },
            error:function(xhr,state,errorThrown){
                //alert("发生网络错误，错误码为：" + xhr.status)
                location.href = "${pageContext.request.contextPath}/error";
            }
        });

    }


    //加载时间控件
    $('.form_datetime').datetimepicker({
        //默认语言
        language: 'zh-CN',
        //默认选择格式
        format: "yyyy-mm-dd hh:ii:ss",
        autoclose: true,
        todayBtn: true,
        startView: 2,
    });


</script>

</body>
</html>
</span>